﻿@*这是手机绑定页面*@

<script>
//    $(function () {
//        popLayer("BM");
//    })
	</script>
<div class="u-mask"></div>
<div class="m-Pop j-Pop j-popC-BM" style="width: 500px">
    <form action="bindMobile" id="subForm">
    <input type="hidden" value="@ViewBag.Token" name="token" />
    <h2>
        <i class="u-clod" onclick="cancleOper();"></i>提&nbsp;&nbsp;示</h2>
	<div class="f-tac loadBg" style="display:none"><img src="../Content/Login/ebulletin/img/loading.gif" /><br/><p style="color:#febf96">正在跳转，请稍等……</p></div>
    <h3>
        服务升级！为了您的账号安全，请绑定您的手机号。</h3>
    <div class="m-form mb10">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td class="f-tar" width="100px">
                    手机号
                </td>
                <td width="210px;">
                    <input class="inpTxt wh200" type="text" id="PhoneNo" name="PhoneNo" />
                </td>
                <td>
                    <p id="phone_tips"></p>
                </td>
            </tr>
            <tr>
                <td class="f-tar">
                    验证码
                </td>
                <td>
                    <input class="inpTxt wh100" type="text" name="codeValue" id="codeValue" />
                    <input type="hidden" name="hidcodeValue" id="hidcodeValue" value="" />
                    <input class="u-inpBtn bgd2e ml2" type="button" value="发送验证码" id="vcodebtn" name="vcodebtn" />
                </td>
                <td>
                    <p id="Code_tips"></p>
                </td>
            </tr>
@*            <tr>
                <td colspan="3" style="text-align:center"><span id="phone_tips"></span></td>
            </tr>*@
            <tr>
                <td>
                    &nbsp;
                </td>
                <td>
                    <input class="u-inpBtn bg2da" type="submit" value="确&nbsp;定"/>
                    <input class="u-inpBtn bge2e ml5" type="button" onclick='cancleOper(this);' value="取消，并登录"/>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>
    </div>
    </form>
</div>
<script>
function cancleOper(sender){
    $(sender).attr("disabled","disabled")
			.parents(".m-form").hide()
			.prev("h3").hide();
	$(".loadBg").show();
    location.href='@Html.Raw(ViewBag.Redirect)';
}

$(function () {
        $("#subForm").submit(function(){
            $.post("@Url.Action("bindMobile")",$("#subForm").serialize(),function(data){
                if(data.s == 0){
                    location.href = "@Html.Raw(ViewBag.Redirect)";
                }else{
                    alert(data.msg);
                }
            });
            return false;
        });
        $("#vcodebtn").removeAttr("disabled"); 
        $("#vcodebtn").bind("click", function () {
            $("#phone_tips").html();
            $("#Code_tips").html();
            var PhoneNo = $("#PhoneNo").val();
            if ($.trim(PhoneNo) == '' || $.trim(PhoneNo).length == 0) {
                $("#phone_tips").html("<img src='../Content/Login/ebulletin/img/error.gif'/><span style='color:red'>@Html._T("请先输入手机号")</span>");
                return;
            }
            var ismobile = /^(?:13\d|15\d|18\d)\d{5}(\d{3}|\*{3})$/; //手机号码验证规则
            if (ismobile.test(PhoneNo)) {
                $("#phone_tips").html("<img src='../Content/Login/ebulletin/img/ok.gif'/>");
            } else {
                $("#phone_tips").html("<img src='../Content/Login/ebulletin/img/error.gif'/><span style='color:red'>@Html._T("手机号码格式不正确")</span>");
                return;
            }
            $.post("@Url.Action("MobileCode")", {PhoneNo:PhoneNo}, function (data) {
                if(data.s != 0){
                    $("#Code_tips").html("<img src='../Content/Login/ebulletin/img/error.gif'/><span style='color:red'>"+data.msg+"</span>");
                }
                else{
                     var count = 60;
                     $("#vcodebtn").attr('disabled',"true");
                     $("#vcodebtn").val(count + "@Html._T("秒后重新发送")");
                     var countdown = setInterval(function(){
                        $("#vcodebtn").attr('disabled',"true");
                        $("#vcodebtn").val(count + "@Html._T("秒后重新发送")");
                        if (count == 0) { 
                            $("#vcodebtn").removeAttr("disabled"); 
                            $("#vcodebtn").val("@Html._T("重新发送")");
                            clearInterval(countdown);
                        }
                        count--;
                     }, 1000);
                }
            });
        });
    });
</script>
